package com.ekosys.util.ObjectCall;

import java_cup.runtime.*;
import java.lang.*;

/**
 * Exception thrown by lexical analizer
 */
class TokenNotFoundException extends Throwable {
  public TokenNotFoundException (String msg, int line, int colum)
    {
      super (msg + " Linea: " + line + " Columna: " + colum);
    }  
}

/**
 * Represents the token shifted into the parser
 */
class Yytoken extends Symbol
{
  private String str_value; 
  private Integer int_value;
  private int token_line;
  private int token_column;

  /**
   * Class constructor with a token code
   */
  Yytoken (int code)
    {
      super (code);
    };
  /**
   * Class constructor with a token code, and a string value
   */
  Yytoken (int code, String str_value, int token_line, int token_column) 
    {
      super (code, str_value);
      this.str_value = str_value;
      this.token_line = token_line;
      this.token_column = token_column;
    }
  /**
   * Class constructor with a token code, and a int value
   */
  Yytoken (int code, Integer int_value, int token_line, int token_column) 
    {
      super (code, int_value);
      this.int_value = int_value;
      this.token_line = token_line;
      this.token_column = token_column;
    }
  /**
   * Gets the token code
   * @return token code
   */
  int getCode ()
    {
      return parse_state;
    }
  /**
   * Gets the int value
   * @return int_value (int)
   */
  Integer getIntValue ()
    {
      return int_value;
    }
  /**
   * Gets the str value
   * @return str_value
   */
  String getStrValue ()
    {
      return str_value;
    }
  /**
   * Gets the token line
   * @return token_line
   */
  int getTokenLine ()
    {
      return token_line;
    }
  /**
   * Gets the token column
   * @return token_column
   */
  int getTokenColumn ()
    {
      return token_column;
    }
  /**
   * Sets the token code
   * @param code the new code for this
   */
  void setCode (int code)
    {
      parse_state = code;
    }
  /**
   * Sets the int value
   * @param int_value the new int int_value for this
   */
  void setIntValue (int int_value)
    {
	this.int_value = new Integer (int_value);
    }
  /**
   * Sets the int value
   * @param int_value the new Integer int_value for this
   */
  void setIntValue (Integer int_value)
    {
	this.int_value = int_value;
    }
  /**
   * Sets the str value
   * @param str_value the new str_value for this
   */
  void setStrValue (String str_value)
    {
	this.str_value = str_value;
    }
  /**
   * Sets the token line
   * @param token_line the new token_line for this
   */
  void setTokenLine (int token_line)
    {
        this.token_line = token_line;
    }
  /**
   * Sets the token column
   * @param token_line the new token_line for this
   */
  void setTokenColumn (int token_column)
    {
        this.token_column = token_column;
    }
}

%%
%line
%char
%cup

%yylexthrow{
  TokenNotFoundException
%yylexthrow}
%eofval{
  return (new Yytoken (sym.EOF));
%eofval}
DIGIT=[0-9]
INTEGER={DIGIT}+
IGNORED=(" "|\n|\t|\f|\r)
ALPHA_LO=[a-z]
ALPHA_UP=[A-Z]
ID=({ALPHA_LO}|{ALPHA_UP}|{DIGIT}|"_")*
SP=(" ")
ANY=([^<>\x20\"])+
MANY=([^\"])*
QUOTE=("\"")
STRING={QUOTE}{MANY}{QUOTE}
%%
<YYINITIAL> {IGNORED}					{}
<YYINITIAL> \n							{yychar = -1;}
<YYINITIAL> "."							{return new Yytoken (sym.DOT,yytext(),yyline + 1,yychar + 1);}
<YYINITIAL> ","							{return new Yytoken (sym.COMMA,yytext(),yyline + 1,yychar + 1);}
<YYINITIAL> "("							{return new Yytoken (sym.OPEN,yytext(),yyline + 1,yychar + 1);}
<YYINITIAL> ")"							{return new Yytoken (sym.CLOSE,yytext(),yyline + 1,yychar + 1);}
<YYINITIAL> {INTEGER}					{return new Yytoken (sym.INTEGER,yytext(),yyline + 1,yychar + 1);}
<YYINITIAL> {STRING}					{return new Yytoken (sym.STRING,yytext(),yyline + 1,yychar + 1);}
<YYINITIAL> {ID}						{return new Yytoken (sym.ID,yytext(),yyline + 1,yychar + 1);}
<YYINITIAL> .							{throw (new TokenNotFoundException(yytext(),yyline + 1,yychar + 1));}